//这里书写属性相关的API文件
import request from "@/utils/request";
//引入ts数据类型
import type{CategoryResponseData ,AttrResponseData} from "@/api/product/attr/type"
//属性管理模块的接口地址
enum API{
    C1_URL = "/admin/product/getCategory1",
    C2_URL = "/admin/product/getCategory2/",
    C3_URL = "/admin/product/getCategory3/",
    //获取分类下已有的属性与属性值
    ATTR_URL="/admin/product/attrInfoList/",
    ADDORUPDATE_URL="/admin/product/saveAttrInfo",
    //删除
    DELETE_URL="/admin/product/deleteAttr/"
    



}
//获取一级分类的接口方法
export const reqC1=()=>request.get<any,CategoryResponseData>(API.C1_URL)
export const reqC2=(category1Id:number|string)=>request.get<any,CategoryResponseData>(API.C2_URL+`${category1Id}`)
export const reqC3=(category2Id:number|string)=>request.get<any,CategoryResponseData>(API.C3_URL+`${category2Id}`)
//获取分类下已有属性与属性的接口
export const reqAttr=(category1Id:number|string,category2Id:number|string,category3Id:number|string)=>request.get<any,AttrResponseData>(API.ATTR_URL+`${category1Id}/${category2Id}/${category3Id}`)
//新增或者修改已有数据的方法
export const reqAddOrUpdateAttr=(data: any)=>request.post<any,any>(API.ADDORUPDATE_URL,data)
//删除已有数据的方法
export const reqRemoveAttr=(attrId:number)=>request.delete<any,any>(API.DELETE_URL + attrId)




